package com.lighting.lightingservice.mapper;

import com.lighting.lightingservice.dto.Page;
import com.lighting.lightingservice.dto.PageList;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;
import org.springframework.web.bind.annotation.RequestBody;

import java.util.List;

@Mapper
public interface PageListMapper {


    //查询全部数据
    @Select("""
            select * from pagelist
            """)
    List<PageList> findAll();

    //修改全部数据
    @Update("""
            update pagelist set 
                value = case id
                when 1 then #{sliderImgUrl1}  
                when 2 then #{sliderTitleUp1} 
                when 3 then #{sliderTitleDown1}
                
                when 4 then #{sliderImgUrl2}  
                when 5 then #{sliderTitleUp2} 
                when 6 then #{sliderTitleDown2}
        
                when 7 then #{sliderImgUrl3}  
                when 8 then #{sliderTitleUp3} 
                when 9 then #{sliderTitleDown3}
        
                when 10 then #{mainVideo}  
                when 11 then #{mainVideoImg} 
        
                when 12 then #{midTitleUp}
                when 13 then #{midTitleDown}
        
                when 14 then #{blockTitle1}
                when 15 then #{blockTitle2}
                when 16 then #{blockTitle3}
                when 17 then #{blockTitle4}
        
                when 18 then #{blockImg1}
                when 19 then #{blockImg2}
                when 20 then #{blockImg3}
                when 21 then #{blockImg4}
        
                when 22 then #{blockVideo1}
                when 23 then #{blockVideo2}
                when 24 then #{blockVideo3}
                when 25 then #{blockVideo4}
            end
            where id in (1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25)
            """)
    void update(Page page);
}
